/**
 * Type Definitions
 */

export interface Config {
  gateway: GatewayConfig;
  discovery: DiscoveryConfig;
  servers: Record<string, ServerConfig>;
  logging: LoggingConfig;
  health?: HealthConfig;
  security?: SecurityConfig;
}

export interface GatewayConfig {
  port: number;
  host: string;
  protocol: 'http' | 'https';
  ssl?: {
    cert: string;
    key: string;
  };
}

export interface DiscoveryConfig {
  enabled: boolean;
  paths: string[];
  npmGlobal?: boolean;
  nodeModules?: boolean;
}

export interface ServerConfig {
  enabled: boolean;
  command: string;
  args?: string[];
  env?: Record<string, string>;
  cwd?: string;
  type?: 'node' | 'python' | 'binary';
  protocol?: 'stdio' | 'http' | 'websocket';
  metadata?: {
    name?: string;
    description?: string;
    version?: string;
    author?: string;
  };
}

export interface LoggingConfig {
  level: 'debug' | 'info' | 'warn' | 'error';
  pretty: boolean;
  file: string | null;
}

export interface HealthConfig {
  enabled: boolean;
  interval: number;
  timeout: number;
}

export interface SecurityConfig {
  requireAuth: boolean;
  authToken: string | null;
  allowedOrigins?: string[];
}

export interface MCPServer {
  id: string;
  name: string;
  description?: string;
  config: ServerConfig;
  status: 'stopped' | 'starting' | 'running' | 'error';
  process?: any;
  lastHealthCheck?: Date;
  tools?: MCPTool[];
}

export interface MCPTool {
  name: string;
  description: string;
  inputSchema?: any;
  outputSchema?: any;
}

export interface MCPRequest {
  jsonrpc: '2.0';
  id: string | number;
  method: string;
  params?: any;
}

export interface MCPResponse {
  jsonrpc: '2.0';
  id: string | number;
  result?: any;
  error?: MCPError;
}

export interface MCPError {
  code: number;
  message: string;
  data?: any;
}